<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> -->
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="./layuimini-v2/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="./layuimini-v2/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form" id="form">
    <!-- <div class="layui-form-item">
        <label class="layui-form-label required">商品名称</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" lay-reqtext="商品不能为空" placeholder="请输入商品名称" value="" class="layui-input">
            <tip>填写商品名称</tip>
        </div>
    </div>
    <div class="layui-form-item" >
        <label class="layui-form-label required">商品种类</label>
        <div class="layui-input-block">
        <select >
            <option name="gender" value="1" >shi</option>
            <option name="gender" value="2">fou</option>
        </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">商品售价</label>
        <div class="layui-input-block">
            <input type="number" name="cashPrice" lay-verify="required" lay-reqtext="商品售价不能为空" placeholder="请输入商品售价" value="" class="layui-input">
            <tip>填写数字格式</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">会员积分价</label>
        <div class="layui-input-block">
            <input type="text" name="pointsPrice" lay-verify="required" lay-reqtext="会员积分价不能为空" placeholder="请输入会员积分价" value="" class="layui-input">
            <tip>填写数字格式</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">是否上架</label>
        <div class="layui-input-block">
            <input type="radio" name="isDelete" value="1" title="是" checked="">
            <input type="radio" name="isDelete" value="2" title="否">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">库存</label>
        <div class="layui-input-block">
            <input type="number" name="stock" lay-verify="required" lay-reqtext="商品库存不能为空" placeholder="请输入商品库存" value="" class="layui-input">
            <tip>填写数字格式</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">热度</label>
        <div class="layui-input-block">
            <input type="number" name="heat" lay-verify="required" lay-reqtext="手机不能为空" placeholder="请设置商品热度" value="" class="layui-input">
        </div>
        <tip>填写数字格式</tip>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div> -->
</div>
<script src="./layuimini-v2/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
 var h='' ;
//  $(function(){
//    $.ajax({
//             url: "http://douzi.wiki:9000/GROW/api/goodsCategory?page=9&limit=0",
//           type: "get",
//           dataType: "json",
//           contentType: "application/json",
//           // async:false,
//           success: function (res) {
//             // alert(1234)
//             console.log(res)
//             console.log(res.msg)
            
//             // if(res.msg==="成功"){       
             
//             //   $.each(res.data,function(i,n){
              
//             //   h+="<option name='gender' value='"+n.id+"' >"+n.name+"</option>"
           
//             //   });
//             //   alert(h)
        
             
//             // }
//             //  document.getElementById('list-box').innerHTML=h
//           },
        
//           error: function (res) {
//             alert("访问失败")
//         }
//     });
// });

         
        var product= JSON.parse(localStorage.getItem('editProduct'))
    console.log(product)
    var f=product
    var is=''
    if(product.isDelete=='0'){
        is+="<div class='layui-form-item'>"+
            "<label class='layui-form-label required'>是否上架</label>"+
                "<div class='layui-input-block'>"+
                    "<input type='radio' name='iseDelete' value='0' title='是' checked=''>"+
                    "<input type='radio' name='iseDelete' value='1' title='否'>"+
                "</div>"+
            "</div>"
    }
    else{
        "<label class='layui-form-label required'>是否上架</label>"+
                "<div class='layui-input-block'>"+
                    "<input type='radio' name='iseDelete' value='0' title='是' >"+
                    "<input type='radio' name='iseDelete' value='1' title='否' checked=''>"+
                "</div>"+
            "</div>"
    }
    var sta=''

    var h=''
    h+="<div class='layui-form-item'>"+
    "<label class='layui-form-label required'>商品名称</label>"+
    "<div class='layui-input-block'>"+
        "<input type='text' name='name' lay-verify='required' lay-reqtext='商品不能为空' placeholder='请输入商品名称' value='"+f.name+"' class='layui-input'>"+
        "<tip>填写商品名称</tip>"+
    "</div>"+
"</div>"+
"<div class='layui-form-item' >"+
    "<label class='layui-form-label required'>商品种类</label>"+
    "<div class='layui-input-block'>"+
    "<select name='tsgoodCategoryId'>"+
       h+
    "</select>"+
    "</div>"+
"</div>"+
"<div class='layui-form-item'>"+
    "<label class='layui-form-label required'>商品售价</label>"+
    "<div class='layui-input-block'>"+
        "<input type='number' name='cashPrice' lay-verify='required' lay-reqtext='商品售价不能为空' placeholder='请输入商品售价' value='"+f.cashPrice+"' class='layui-input'>"+
        "<tip>填写数字格式</tip>"+
    "</div>"+
"</div>"+
"<div class='layui-form-item'>"+
    "<label class='layui-form-label required'>会员积分价</label>"+
    "<div class='layui-input-block'>"+
        "<input type='text' name='pointsPrice' lay-verify='required' lay-reqtext='会员积分价不能为空' placeholder='请输入会员积分价' value='"+f.pointsPrice+"' class='layui-input'>"+
        "<tip>填写数字格式</tip>"+
    "</div>"+
"</div>"+
is+
// "<div class='layui-form-item'>"+
//     "<label class='layui-form-label required'>是否上架</label>"+
//     "<div class='layui-input-block'>"+
//         "<input type='radio' name='isDelete' value='1' title='是' checked=''>"+
//         "<input type='radio' name='isDelete' value='2' title='否'>"+
//     "</div>"+
// "</div>"+
"<div class='layui-form-item'>"+
    "<label class='layui-form-label required'>库存</label>"+
    "<div class='layui-input-block'>"+
        "<input type='number' name='stock' lay-verify='required' lay-reqtext='商品库存不能为空' placeholder='请输入商品库存' value='"+f.stock+"' class='layui-input'>"+
        "<tip>填写数字格式</tip>"+
    "</div>"+
"</div>"+
"<div class='layui-form-item'>"+
    "<label class='layui-form-label required'>热度</label>"+
    "<div class='layui-input-block'>"+
        "<input type='number' name='heat' lay-verify='required' lay-reqtext='手机不能为空' placeholder='请设置商品热度' value='"+f.heat+"' class='layui-input'>"+
    "</div>"+
    "<tip>填写数字格式</tip>"+
"</div>"+

"<div class='layui-form-item'>"+
    "<div class='layui-input-block'>"+
        "<button class='layui-btn layui-btn-normal' lay-submit lay-filter='saveBtn'>确认修改</button>"+
    "</div>"+
"</div>"
document.getElementById('form').innerHTML=h
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
    //         $.ajax({
	// 	type: "post",
	// 	contentType:"application/json",
	// 	dataType: 'json',
	// 	data:JSON.stringify(data),
	// 	url: "http://www.demo.com/test/test",
	// 	success: function(data) {
	// 			console.log(data)
	// 	}
	// });



            var index = layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            }, function () {

                // 关闭弹出层
                layer.close(index);

                var iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.layer.close(iframeIndex);

            });

            return false;
        });

    });
</script>
</body>
</html>